<?php 
session_start(); 
require_once('../include/connect.inc.php');
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
			alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
			location="login.php";
</script>
<?php }?>
<?php
	$msg="";
             $query = query("SELECT * FROM tb_choice  where choice_id ='".$_GET[choice_id]."'");
		while ($rs = fetch_array($query)){
			$choice_id=$rs['choice_id'];	
			$choice_detail=$rs['choice_detail'];
			$answer=$rs['answer'];
			}
		if($_GET[op]=="edit"){
		$strSql="update tb_choice set choice_detail='".$_POST[choice_detail]."',answer='".$_POST[answer]."' where choice_id='".$_POST[choice_id]."'";
		$rs = execute($strSql);
	if(!$rs) {
		$msg = "เกิดข้อผิดพลาดโปรดทำรายการใหม่";
			header("location:frm_edit_choice.php");
	} else {
	?>
    <SCRIPT LANGUAGE="JavaScript">
			alert("คุณได้ทำการแก้ไขคำตอบเรียบร้อยแล้ว");
			location="frm_edit_question.php?question_id=<?php echo $question_id;?>";
			</script>
<?php
			exit();
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="../template/template_style_wood.css">
</head>

<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a  href="../person_tea.php">ข้อมูลส่วนตัว</a>
		<a href="../tea_edit.php">เปลี่ยนรหัสผ่านใหม่</a>
        
        <a href="show_subject.php">จัดการรายวิชา</a>
		<a class="active" href="../teacher_test.php">จัดการข้อสอบ</a>
        <a href="../teacher_tests.php">จัดการชุดข้อสอบ</a>
        <a  href="../agree_set.php">กำหนดสิทธิ์</a>
		<a href="../exam/tea_chack.php">ตรวจสอบคะแนน</a>
        <a href="../news/manage_news.php">ประกาศข่าวสาร</a>
        <a href="../problem/send_problem.php">แสดงความคิดเห็น</a>
        <a href="../logout.php">ออกจากระบบ</a>
		</div></div>           
 <div id="p3">    
<div id="header"></div>
   <div id="page"><div id="p1">คุณ<?php echo $_SESSION['teacher_name'];?><hr/>
<form id="form1" name="form1" method="post" action="frm_edit_choice.php?op=edit&question_id=<?php echo $question_id;?>">
	<table  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left">แก้ไขคำตอบ</th>
        <th align="right"><a href="frm_edit_question.php?question_id=<?php echo $question_id;?>">
        <img src="../images/undo.png" border="0" /></a></th>
      </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" id="table-c" >
        <tr>
        <td><input name="choice_detail" type="text" id="choice_detail" value="<?  echo $choice_detail;?>"/>
        <? if($answer==$question_id){ echo " "; ?>
        			<? } else {  ?>
                         <input type="radio" name="answer" id="answer" value="1" <? if($answer=="1") 
						  echo " checked='checked'"; ?> />ถูก
 						<input type="radio" name="answer" id="answer" value="0" <? if($answer=="0") 
						  echo " checked='checked'"; ?> />  ผิด
                          <? } ?>
        		</td>
 		<tr>
        <td><input type="hidden" name="hiddenField" id="hiddenField" />
          <input type="submit" name="submit" id="submit" value="บันทึก" />
         <input type="reset" name="cancel" id="cancel" value="ยกเลิก" />
         <input type="hidden" name="choice_id" id="choice_id" value="<? echo $_GET[choice_id]; ?>" /></td>	
        </tr>
 </table>
</form>
 </div>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>
